package com.goldsprite.microhorigame.screens.examples.spinegfsmexamples;

public enum CharacterType {
	FEMALE_SWORDSMAN(
		new CharacterConfig()
			.setDataPath("spine/cgjoy-女剑士/exports/NPC_30")
			.setScale(0.75f)
			.setYOffset(-100f)
			.addAnim(AnimType.IDLE, "idle")
			.addAnim(AnimType.MOVE, "move")
			.addAnim(AnimType.ATTACK, "attack")
	),

	PLAYER1(
		new CharacterConfig()
			.setDataPath("spine/Player1/exports/Player")
			.setScale(0.67f)
			.setYOffset(-180f)
			.addAnim(AnimType.IDLE, "Idle_R")
			.addAnim(AnimType.MOVE, "WalkLoop_R")
			.addAnim(AnimType.ATTACK, "AttackLand_R")
	),

	LIAN(
		new CharacterConfig()
			.setDataPath("spine/100361怜/exports/100361")
			.setScale(0.7f)
			.setYOffset(-100f)
			.addAnim(AnimType.IDLE, "04_idle")
			.addAnim(AnimType.MOVE, "04_walk")
			.addAnim(AnimType.ATTACK, "04_attack")
	),

	COU(
		new CharacterConfig()
			.setDataPath("spine/100431凑/exports/100461")
			.setScale(1f)
			.setYOffset(-75f)
			.addAnim(AnimType.IDLE, "01_idle")
			.addAnim(AnimType.MOVE, "01_walk")
			.addAnim(AnimType.ATTACK, "01_attack")
	),

	KNIGHT(
		new CharacterConfig()
			.setDataPath("spine/Knight/exports/Knight")
			.setScale(0.75f)
			.setYOffset(-75f)
			.addAnim(AnimType.IDLE, "idle_3")
			.addAnim(AnimType.MOVE, "walk")
			.addAnim(AnimType.ATTACK, "sword_attack")
			.addAnim(AnimType.JUMP, "jump") // 为骑士添加跳跃动画
	),

	SeveredFang(
		new CharacterConfig()
			.setDataPath("spine/severedFang/exports/severedFang")
			.setScale(0.75f)
			.setYOffset(-75f)
			.addAnim(AnimType.IDLE, "idle_3")
			.addAnim(AnimType.MOVE, "walk_shield")
			.addAnim(AnimType.ATTACK, "sword_attack")
			.addAnim(AnimType.JUMP, "jump")
	);

	private final CharacterConfig config;

	CharacterType(CharacterConfig config) {
		this.config = config;
	}

	public CharacterConfig getConfig() {
		return config;
	}

	// 获取下一个角色（循环）
	public CharacterType next() {
		CharacterType[] values = values();
		return values[(this.ordinal() + 1) % values.length];
	}

	// 获取上一个角色（循环）
	public CharacterType previous() {
		CharacterType[] values = values();
		int index = (this.ordinal() - 1 + values.length) % values.length;
		return values[index];
	}

	// 按名称获取角色
	public static CharacterType getByName(String name) {
		try {
			return CharacterType.valueOf(name.toUpperCase());
		} catch (IllegalArgumentException e) {
			return FEMALE_SWORDSMAN; // 默认角色
		}
	}

	// 获取所有角色名称
	public static String[] getNames() {
		CharacterType[] types = values();
		String[] names = new String[types.length];
		for (int i = 0; i < types.length; i++) {
			names[i] = types[i].name();
		}
		return names;
	}
}
